﻿@model IEnumerable<VacationsRequest.Models.VacationsReportByManager>
@{
    ViewBag.Title = "VacationsReportByManager";

    RouteValueDictionary rvd = Request.QueryString.ToRouteValues();
    if (!rvd.Keys.Contains("sortOrder"))
    {
        rvd.Add("sortOrder", null);
    }
}
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#result").dialog({
            autoOpen: false,

            width: 'auto',
            height: 'auto',
            modal: true
        });
    });
    function openPopup(ptitle) {
        $("#result").dialog("option", "title", ptitle)
        $("#result").dialog("open");
    }
</script>
<h2>
    Vacations Report By Manager</h2>
<p>
    @using (Html.BeginForm("VacationsReportByManager", "Employees", FormMethod.Get))
    {   
        <p>
            Manager: @Html.DropDownList("managerString", "All")
            Team: @Html.DropDownList("teamString", "All")
            Name: @Html.TextBox("SearchString")
            <input type="submit" value="Filter" /></p>
    }
</p>
<table>
    <tr>
        <th>
            @{ rvd["sortOrder"] = ViewBag.TeamSortParm; }
            @Html.ActionLink("Team", "VacationsReportByManager", rvd)
        </th>
        <th>
            @{ rvd["sortOrder"] = ViewBag.ManagerSortParam; }
            @Html.ActionLink("Manager", "VacationsReportByManager", rvd)
        </th>
        <th>
            @{ rvd["sortOrder"] = ViewBag.EmployeeSortParm; }
            @Html.ActionLink("Employee Name", "VacationsReportByManager", rvd)
        </th>
        <th>
            @{ rvd["sortOrder"] = ViewBag.StartDateSortParm; }
            @Html.ActionLink("Start Date", "VacationsReportByManager", rvd)
        </th>
        <th>
            @{ rvd["sortOrder"] = ViewBag.TotVacSortParm; }
            @Html.ActionLink("Total Vacations", "VacationsReportByManager", rvd)
        </th>
        <th>
            @{ rvd["sortOrder"] = ViewBag.RemVacSortParm; }
            @Html.ActionLink("Remaining Vacations", "VacationsReportByManager", rvd)
        </th>
        <th>
            @{ rvd["sortOrder"] = ViewBag.TakVacSortParm; }
            @Html.ActionLink("Taken Vacations", "VacationsReportByManager", rvd)
        </th>
        <th>
            @{ rvd["sortOrder"] = ViewBag.ResVacSortParm; }
            @Html.ActionLink("Reserved Vacations", "VacationsReportByManager", rvd)
        </th>
    </tr>
    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Team)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Managers)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Name)
            </td>
            <td style="text-align: right;">
                @Html.DisplayFor(modelItem => item.HireDate)
            </td>
            <td style="text-align: center;">
                @Html.DisplayFor(modelItem => item.TotalVac)
            </td>
            <td style="text-align: center;">
                @Html.DisplayFor(modelItem => item.VacPending)
            </td>
            <td style="text-align: center;">
                @Ajax.ActionLink(item.VacTaken.ToString(), "VacationsListPartial", "VacationDays", new { id = item.ID, type = "Taken" }, new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "result", InsertionMode = InsertionMode.Replace, OnSuccess = "openPopup('Taken Vacations')" })
            </td>
            <td style="text-align: center;">
                @Ajax.ActionLink(item.Reserved.ToString(), "VacationsListPartial", "VacationDays", new { id = item.ID, type = "Pending" }, new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "result", InsertionMode = InsertionMode.Replace, OnSuccess = "openPopup('Reserved Vacations')" })
            </td>
        </tr>
    }
</table>
<div id="result" style="display: none;">
</div>
